home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
fhard101.zip
/
VHARD.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-07-22
|
58KB
|
2,120 lines
title Fake hard disk driver
subttl Prologue
page 60,132
comment {
******************************************************************************
File VHARD.ASM
Author:
Aaron L. Brenner
BIX mail address albrenner
GEnie address A.BRENNER
This program is hereby released to the public domain.
Purpose:
A DOS device driver that will make a floppy drive double as a small
hard disk.
This is accomplished by spreading the fake HD over a series of
diskettes. The disks must be prepared (with VHPREP) by formatting to
10 sectors/track for a capacity of 400KB per diskette. Also, VHPREP
will stamp each diskette with a unique ID built from the date and time
the first diskette was prepared and the sequence number of it. VHPREP
is also responsible for performing the low and high level format on
all disks. Formatting is performed by the driver, but under VHPREP
control.
VHPREP communicates with the driver via a dummy character device
driver named VHARDCTL, which will provide access to driver functions.
The only driver command supported is IOCTL Write (all others are
NOPs), and only 7 bytes are actually used. These 7 bytes are treated
as a command block, structured as follows:
Format command
byte 0
byte track to format (head in bit 7, cylinder in low 7 bits)
byte return status
dword pointer to format parameter buffer (see details in int 13h)
Read Track command
byte 1
byte track to read (head in bit 7, cylinder in low 7 bits)
byte return status
dword pointer to buffer to read into
Write Track command
byte 2
byte track to write (head in bit 7, cylinder in low 7 bits)
byte return status
dword pointer to buffer to write from
Verify Track command
byte 3
byte track to verify (head in bit 7, cylinder in low 7 bits)
byte return status
Set FAT cache buffer
byte 4
byte == 0, disable cache
== 1, enable cache
== 2, flush cache
== 3, disable cache autoflush
== 4, enable cache autoflush (DOS 3+, SHARE installed)
== 5, return information about the cache
byte return status
dword pointer to cache buffer
This command is used to enable or disable the FAT/directory cache.
Once the cache is enabled, logical sectors 1 through 24 will be cached
for both read and write. They will only be written when driver
function 14 (Device close) is called AND the reference count is 0.
To accomodate older versions of DOS, subcommand 2 will manually flush
the cache to disk. Subcommands 3 & 4 will disable or enable the
auto-flush.
Retrieve Driver Data
byte 5
byte unused
byte set to 0 by VHARD
dword pointer to buffer to receive the following data:
byte drive number assigned by DOS
word VHARD version
19 bytes BPB for VHARD
Revision history:
0.90 06/27/90 ALB Created. This version uses 13 360KB diskettes
for appx. 5MB of faked hard disk space. Note:
cache handling is NOT yet implemented.
******************************************************************************
endcomment {
subttl Included files
page
include dd_defs.inc
include vhard.inc ; Some structures we use
DEBUG equ 0
subttl Macros and templates
page
BIOS_seg segment at 40h
org 62h
active_page db ?
org 84h
crt_lines db ?
BIOS_seg ends
;*****************************************************************************
;
; Version of VHARD
;
;*****************************************************************************
VHARD_version equ 100h
VHARD_text_ver equ <'1.00'>
subttl Device driver headers
page
vhard_seg segment
org 0
assume cs:vhard_seg, ds:nothing, es:nothing, ss:nothing
;
; Declare the header for the dummy char device used to communicate with
; the block driver
;
dw offset next_hdr
nextdvrseg dw -1
dw DA_IS_CHAR or DA_IOCTL
dw strategy
dw du_int
db 'VHARDCTL'
;
; Declare the header for the device driver
; Attributes:
; block device
; removable media
;
next_hdr dw -1, -1
dw DA_IS_BLK or DA_IS_REM
dw strategy
dw vh_int
db 1, 'VHARD '
subttl Device driver data
page
;
; Pointer passed by DOS to the request packet
;
req_ptr dw 0, 0
;
; Version of DOS
;
dos_ver dw 0
;
; Local copy of the diskette parameters
;
diskparms db 4 dup(0) ; Gets filled in at init time
sect_per_track db 0 ; Sectors per track (set at init time)
gap_len db 0
db 0
fmt_gap_len db 0
db 3 dup(0)
;
; Save area for old parm pointer
;
old_pptr dw 0, 0
;
; ID and # for the current disk
;
curr_disk_id db 'NO NAME',0
db 0
curr_disk_num db 0ffh
;
; Counter of how many sectors read/written
;
io_count dw 0
;
; Count of how many sectors to go
;
io_to_go dw 0
;
; Flag indicating whether or not we have EGA/VGA video available. This is used
; in the prompt_user routine - if have_evga != 0, then we read the number of
; character lines on screen from 40:84. If have_evga == 0, then we always use
; line 24.
;
have_evga db 0
last_curs dw 0
;
; If we're running under DOS 3.10 or higher, we get the drive number assigned
; from the the request block and save it here.
;
our_drive db 0ffh
;
; Data used to manage the FAT/dir cache.
;
cache_ptr dw 0,0 ; Pointer to the cache
cache_flags db 0 ; Bit flags
;
; Messages that get displayed at various times
;
need_disk db 'Put disk ID '
pr_disk_id db 8 dup(' ')
db ' #'
pr_disk_num db ' '
db ' in drive A:, then press a key',0
need_first_disk db 'Put disk #0 of the set you want to use'
db ' in drive A:, then press a key',0
;
; Save area for the chunk of screen we diddle
;
screen_save dw 80 dup(0)
;
; Buffer for the boot sector (containing ID, etc.)
;
boot_sect_buf db 512 dup(0)
;*****************************************************************************
;
; These 2 tables are used to translate BIOS error codes into the status codes
; expected by DOS and VHPREP, respectively
;
;*****************************************************************************
DOS_sts_table db 80h, DE_NOT_READY
db 40h, DE_SEEK_ERROR
db 20h, DE_GEN_FAIL
db 10h, DE_CRC_ERROR
db 9, DE_WRITE_FAULT
db 8, DE_WRITE_FAULT
db 4, DE_NOT_FOUND
db 3, DE_WRITE_PROT
db 2, DE_GEN_FAIL
db 1, DE_GEN_FAIL
CMD_sts_table db 80h, STS_TIMEOUT
db 40h, STS_BAD_SEEK
db 20h, STS_BAD_NEC
db 10h, STS_BAD_CRC
db 9, STS_DMA_BOUND
db 8, STS_BAD_DMA
db 4, STS_NOT_FND
db 3, STS_WRITE_PROT
db 2, STS_ADDR_MARK
db 1, STS_BAD_CMD
;*****************************************************************************
;
; BIOS parameter block (BPB) that DOS is going to use
;
;*****************************************************************************
our_bpb DOS_BPB <512, 8, 1, 2, 256, (13 * 799), 0fch, 4, 47, 26, 0>
our_bpb_array dw offset our_bpb
;*****************************************************************************
;
; For this version, at least, this driver will support the OPEN and CLOSE
; calls. These will increment and decrement a reference counter that will be
; used to know when to the write the FAT cache (if caching is enabled).
;
;*****************************************************************************
ref_count dw 0
subttl Device driver STRATEGY and INTERRUPT routines
page
;*****************************************************************************
;
; Strategy entry point. Used for both drivers
;
;*****************************************************************************
strategy proc far
mov cs:req_ptr[0],bx ; Save the pointer
mov cs:req_ptr[2],es ;
ret ; Return to DOS
strategy endp
;*****************************************************************************
;
; Interrupt routine for the VH driver
;
;*****************************************************************************
vh_int proc far
assume ds:nothing, es:nothing
call save_regs ; Save the registers
cld ; Make sure of direction
push cs ; Set DS to our segment
pop ds ;
assume ds:vhard_seg
if DEBUG
call dump_entry
endif
les si,dword ptr req_p